/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "proveedores")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Proveedores.findAll", query = "SELECT p FROM Proveedores p"),
    @NamedQuery(name = "Proveedores.findByIdProv", query = "SELECT p FROM Proveedores p WHERE p.idProv = :idProv"),
    @NamedQuery(name = "Proveedores.findByNomProv", query = "SELECT p FROM Proveedores p WHERE p.nomProv = :nomProv"),
    @NamedQuery(name = "Proveedores.findByDirecProv", query = "SELECT p FROM Proveedores p WHERE p.direcProv = :direcProv"),
    @NamedQuery(name = "Proveedores.findByPais", query = "SELECT p FROM Proveedores p WHERE p.pais = :pais"),
    @NamedQuery(name = "Proveedores.findByCodPostal", query = "SELECT p FROM Proveedores p WHERE p.codPostal = :codPostal"),
    @NamedQuery(name = "Proveedores.findByEmail", query = "SELECT p FROM Proveedores p WHERE p.email = :email"),
    @NamedQuery(name = "Proveedores.findByFono", query = "SELECT p FROM Proveedores p WHERE p.fono = :fono"),
    @NamedQuery(name = "Proveedores.findByFono2", query = "SELECT p FROM Proveedores p WHERE p.fono2 = :fono2"),
    @NamedQuery(name = "Proveedores.findByWebSite", query = "SELECT p FROM Proveedores p WHERE p.webSite = :webSite")})
public class Proveedores implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Prov")
    private Integer idProv;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 80)
    @Column(name = "Nom_Prov")
    private String nomProv;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 240)
    @Column(name = "Direc_Prov")
    private String direcProv;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Pais")
    private String pais;
    @Size(max = 45)
    @Column(name = "Cod_Postal")
    private String codPostal;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 100)
    @Column(name = "Email")
    private String email;
    @Size(max = 30)
    @Column(name = "Fono")
    private String fono;
    @Size(max = 30)
    @Column(name = "Fono2")
    private String fono2;
    @Size(max = 200)
    @Column(name = "WebSite")
    private String webSite;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idProv")
    private Collection<OrdenCompra> ordenCompraCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idProv")
    private Collection<ProvHasProd> provHasProdCollection;

    public Proveedores() {
    }

    public Proveedores(Integer idProv) {
        this.idProv = idProv;
    }

    public Proveedores(Integer idProv, String nomProv, String direcProv, String pais) {
        this.idProv = idProv;
        this.nomProv = nomProv;
        this.direcProv = direcProv;
        this.pais = pais;
    }

    public Integer getIdProv() {
        return idProv;
    }

    public void setIdProv(Integer idProv) {
        this.idProv = idProv;
    }

    public String getNomProv() {
        return nomProv;
    }

    public void setNomProv(String nomProv) {
        this.nomProv = nomProv;
    }

    public String getDirecProv() {
        return direcProv;
    }

    public void setDirecProv(String direcProv) {
        this.direcProv = direcProv;
    }

    public String getPais() {
        return pais;
    }

    public void setPais(String pais) {
        this.pais = pais;
    }

    public String getCodPostal() {
        return codPostal;
    }

    public void setCodPostal(String codPostal) {
        this.codPostal = codPostal;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFono() {
        return fono;
    }

    public void setFono(String fono) {
        this.fono = fono;
    }

    public String getFono2() {
        return fono2;
    }

    public void setFono2(String fono2) {
        this.fono2 = fono2;
    }

    public String getWebSite() {
        return webSite;
    }

    public void setWebSite(String webSite) {
        this.webSite = webSite;
    }

    @XmlTransient
    public Collection<OrdenCompra> getOrdenCompraCollection() {
        return ordenCompraCollection;
    }

    public void setOrdenCompraCollection(Collection<OrdenCompra> ordenCompraCollection) {
        this.ordenCompraCollection = ordenCompraCollection;
    }

    @XmlTransient
    public Collection<ProvHasProd> getProvHasProdCollection() {
        return provHasProdCollection;
    }

    public void setProvHasProdCollection(Collection<ProvHasProd> provHasProdCollection) {
        this.provHasProdCollection = provHasProdCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idProv != null ? idProv.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Proveedores)) {
            return false;
        }
        Proveedores other = (Proveedores) object;
        if ((this.idProv == null && other.idProv != null) || (this.idProv != null && !this.idProv.equals(other.idProv))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Proveedores[ idProv=" + idProv + " ]";
    }
    
}
